import factory.OSFactory;
import factory.impl.LinuxFactory;
import factory.impl.MacOSFactory;
import factory.impl.WindowsFactory;
import os.OperatingSystem;

/**
 * 工厂方法模式，隐藏实例化细节
 * 提供创建对象的接口，让子类决定实例化哪一个类
 */
public class Main {
    public static void main(String[] args) {
        OSFactory factory;
        factory = new WindowsFactory(2024);
        OperatingSystem windows = factory.getOS();
        windows.open();
        System.out.println(windows.type());
        windows.close();

        factory = new LinuxFactory(202453);
        OperatingSystem linux = factory.getOS();
        linux.open();
        System.out.println(linux.type());
        linux.close();

        factory = new MacOSFactory(Integer.MAX_VALUE);
        OperatingSystem macOS = factory.getOS();
        macOS.open();
        System.out.println(macOS.type());
        macOS.close();



    }
}